<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>myGame</title>
		<script type="text/javascript" src="../lufylegend-1.7.7.js"></script>
</head>
<body>	
			<div id="legend"></div>
<script>

LSystem.screen(LStage.FULL_SCREEN);
init(30,"legend",1024,768,main);
var backLayer;

var imglist;


var armyBuilding10Layer;
var armyBuilding9Layer;
var armyBuilding8Layer;
var armyBuilding7Layer;
var armyBuilding6Layer;
var armyBuilding5Layer;
var armyBuilding4Layer;
var armyBuilding3Layer;
var armyBuilding2Layer;
var armyBuilding1Layer;

var armyBuilding1;
var armyBuilding2;
var armyBuilding3;
var armyBuilding4;
var armyBuilding5;
var armyBuilding6;
var armyBuilding7;
var armyBuilding8;
var armyBuilding9;
var armyBuilding10;


var armyList =[];
var imgData = [
		{name:"back",path:"./images/back.jpg"},
		{name:"item1",path:"./images/item/item1.gif"},
		{name:"item2",path:"./images/item/item2.gif"},
		{name:"item3",path:"./images/item/item3.gif"},
		{name:"item4",path:"./images/item/item4.gif"},
		{name:"item5",path:"./images/item/item5.gif"},
		{name:"item6",path:"./images/item/item6.gif"},
		
		
		{name:"armyBuilding1",path:"./images/armyBuilding/armyBuilding1.png"},
		{name:"armyBuilding2",path:"./images/armyBuilding/armyBuilding2.png"},
		{name:"armyBuilding3",path:"./images/armyBuilding/armyBuilding3.png"},
		{name:"armyBuilding4",path:"./images/armyBuilding/armyBuilding4.png"},
		{name:"armyBuilding5",path:"./images/armyBuilding/armyBuilding5.png"},
		{name:"armyBuilding6",path:"./images/armyBuilding/armyBuilding6.png"},
		{name:"armyBuilding7",path:"./images/armyBuilding/armyBuilding7.png"},
		{name:"armyBuilding8",path:"./images/armyBuilding/armyBuilding8.png"},
		{name:"armyBuilding9",path:"./images/armyBuilding/armyBuilding9.png"},
		{name:"armyBuilding10",path:"./images/armyBuilding/armyBuilding10.png"},
 		
		
		{name:"armyer1",path:"./images/armyer/armyer1.png"},
		{name:"armyer2",path:"./images/armyer/armyer2.png"},
		{name:"armyer3",path:"./images/armyer/armyer3.png"},
		{name:"armyer4",path:"./images/armyer/armyer4.png"},
		{name:"armyer5",path:"./images/armyer/armyer5.png"},
		{name:"armyer6",path:"./images/armyer/armyer6.png"},
		{name:"armyer7",path:"./images/armyer/armyer7.png"},
		{name:"armyer8",path:"./images/armyer/armyer8.png"},
		{name:"armyer9",path:"./images/armyer/armyer9.png"},
		{name:"armyer10",path:"./images/armyer/armyer10.png"}
]


function main()
{
	LLoadManage.load(imgData,null,gameInit);
}
function gameInit(result){
	imglist = result;
	backLayer = new LSprite();
	addChild(backLayer);
	
	addBackGround();
	addMyAmeyBuilding();
	
	
	backLayer.addEventListener(LEvent.ENTER_FRAME,onframe);
	// backLayer.addEventListener(LMouseEvent.MOUSE_UP,onup);
}	

function addBackGround()
{
	var bitmap=new LBitmap(new LBitmapData(imglist["back"]));
	backLayer.addChild(bitmap);
}

function addMyAmeyBuilding()
{
	
	armyBuilding1= new LBitmap(new LBitmapData(imglist["armyBuilding1"]));
	armyBuilding1.x = 0;
	armyBuilding1.y = 64;
	armyBuilding1Layer = new LSprite();
	armyBuilding1Layer.addChild(armyBuilding1);
	backLayer.addChild(armyBuilding1Layer);
	armyBuilding1Layer.addEventListener(LMouseEvent.MOUSE_UP,onup1);
	
	
	armyBuilding2= new LBitmap(new LBitmapData(imglist["armyBuilding2"]));
	armyBuilding2.x = 0;
	armyBuilding2.y = 128 +64;
	armyBuilding2Layer = new LSprite();
	armyBuilding2Layer.addChild(armyBuilding2);
	backLayer.addChild(armyBuilding2Layer);
	armyBuilding2Layer.addEventListener(LMouseEvent.MOUSE_UP,onup2);
	
	armyBuilding3= new LBitmap(new LBitmapData(imglist["armyBuilding3"]));
	armyBuilding3.x = 0;
	armyBuilding3.y = 256+64;
	armyBuilding3Layer = new LSprite();
	armyBuilding3Layer.addChild(armyBuilding3);
	backLayer.addChild(armyBuilding3Layer);
	armyBuilding3Layer.addEventListener(LMouseEvent.MOUSE_UP,onup3);
	
	armyBuilding4= new LBitmap(new LBitmapData(imglist["armyBuilding4"]));
	armyBuilding4.x = 0;
	armyBuilding4.y = 256+128+64;
	armyBuilding4Layer = new LSprite();
	armyBuilding4Layer.addChild(armyBuilding4);
	backLayer.addChild(armyBuilding4Layer);
	armyBuilding4Layer.addEventListener(LMouseEvent.MOUSE_UP,onup4);
	
	armyBuilding5= new LBitmap(new LBitmapData(imglist["armyBuilding5"]));
	armyBuilding5.x = 0;
	armyBuilding5.y = 512+64;
	armyBuilding5Layer = new LSprite();
	armyBuilding5Layer.addChild(armyBuilding5);
	backLayer.addChild(armyBuilding5Layer);
	armyBuilding5Layer.addEventListener(LMouseEvent.MOUSE_UP,onup5);
	
	
	
	armyBuilding6= new LBitmap(new LBitmapData(imglist["armyBuilding6"]));
	armyBuilding6.x = 1024-128;
	armyBuilding6.y = 64;
	armyBuilding6Layer = new LSprite();
	armyBuilding6Layer.addChild(armyBuilding6);
	backLayer.addChild(armyBuilding6Layer);
	armyBuilding6Layer.addEventListener(LMouseEvent.MOUSE_UP,onup6);
	
	armyBuilding7= new LBitmap(new LBitmapData(imglist["armyBuilding7"]));
	armyBuilding7.x = 1024-128;
	armyBuilding7.y = 128 +64;
	armyBuilding7Layer = new LSprite();
	armyBuilding7Layer.addChild(armyBuilding7);
	backLayer.addChild(armyBuilding7Layer);
	armyBuilding7Layer.addEventListener(LMouseEvent.MOUSE_UP,onup7);
	
	armyBuilding8= new LBitmap(new LBitmapData(imglist["armyBuilding8"]));
	armyBuilding8.x = 1024-128;
	armyBuilding8.y = 256+64;
	armyBuilding8Layer = new LSprite();
	armyBuilding8Layer.addChild(armyBuilding8);
	backLayer.addChild(armyBuilding8Layer);
	armyBuilding8Layer.addEventListener(LMouseEvent.MOUSE_UP,onup8);
	
	armyBuilding9= new LBitmap(new LBitmapData(imglist["armyBuilding9"]));
	armyBuilding9.x = 1024-128;
	armyBuilding9.y = 256+128+64;
	armyBuilding9Layer = new LSprite();
	armyBuilding9Layer.addChild(armyBuilding9);
	backLayer.addChild(armyBuilding9Layer);	
	armyBuilding9Layer.addEventListener(LMouseEvent.MOUSE_UP,onup9);
	
	armyBuilding10= new LBitmap(new LBitmapData(imglist["armyBuilding10"]));
	armyBuilding10.x = 1024-128;
	armyBuilding10.y = 512+64;
	armyBuilding10Layer = new LSprite();
	armyBuilding10Layer.addChild(armyBuilding10);
	backLayer.addChild(armyBuilding10Layer);
	armyBuilding10Layer.addEventListener(LMouseEvent.MOUSE_UP,onup10);
}

				
function onup1(e)
{
	// armyBuilding1.bitmapData = new LBitmapData(imglist["armyBuilding2"]);
	armyBuilding1Layer.visible = false;
	// alert("xxxxxxxxx");
	
	var armyer = new LBitmap(new LBitmapData(imglist["armyer1"]));
	var sp = new LSprite();
	armyer.x = armyBuilding1.x;
	armyer.y = armyBuilding1.y;
	sp.addChild(armyer);
	backLayer.addChild(sp);
	sp.addEventListener(LMouseEvent.MOUSE_UP,onup10);
	
	var o = {};
	o.bitmap = armyer;
	o.sprite = sp;
	armyList.push(o);
}

function onup2(e)
{
}
function onup3(e)
{
}
function onup4(e)
{
}
function onup5(e)
{
}
function onup6(e)
{
}
function onup7(e)
{
}
function onup8(e)
{
}
function onup9(e)
{
}
function onup10(e)
{
	armyBuilding1Layer.visible = true;
	alter("xxx");
}

function onframe()
{
	// for (var i=0; i < armyList.length; i++) 
	// {
	  // var o = armyList[i];
	  // o.bitmap = o.bitmap + 10;
	// };
	alter("xxx");
}
</script>
	</body>
</html>